	<input type="hidden" class="layui-input"  name="dataSource.id" value="#(dataSource.id??)" />
#(token)
<div class="layui-row layui-col-space1 task-row">
	#set(labelWidth=115)
	 #@colStart("dbType",6)
	 <select id="dbType" name="dataSource.dbType" class="layui-select" lay-filter="dbTypeFilter">
	 	<option value="mysql">MySQL</option>
	 	<option value="oracle">Oracle</option>
	 	<option value="ssql">SQLServer</option>
	 	<option value="psql">PostgreSQL</option>
	 </select>
	 #@colEnd() 
	 
	 #set(req=true)
	 #@colStart("configName",6)
	<input type="text" id="configName" class="layui-input #if(dataSource&&!e) layui-disabled #end" #if(dataSource&&!e) readonly #end 
		name="dataSource.configName" value="#(dataSource.config_name??)" lay-verType='tips'lay-verify="required" 
		maxlength="100" placeholder="使用示例：Db.use(configName)"/>
	 #@colEnd() 
</div>
<div class="layui-row layui-col-space1 task-row">
	 #set(req=true)
	 #@colStart("user",6)
	<input type="text" class="layui-input" id="user"  name="dataSource.user" value="#(dataSource.user??'root')" lay-verType='tips'lay-verify="required" maxlength="100"/>
	 #@colEnd() 
	 
	 #set(req=true)
	 #@colStart("password",6)
	<input type="text" class="layui-input" id="password" name="dataSource.password" value="#(dataSource.password??)" lay-verType='tips'lay-verify="required" maxlength="100"/>
	 #@colEnd() 
</div>
<div class="layui-row layui-col-space1 task-row"> 
	 #set(req=true)
	 #@colStart("jdbcUrl",10)
	<input type="text" class="layui-input" id="jdbcUrl" name="dataSource.jdbcUrl" value="#(dataSource.jdbc_url??'jdbc:mysql://localhost/database?characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true')" lay-verType='tips'lay-verify="required"/>
	 #@colEnd() 
	 
	 #set(labelWidth=0)
	 #@colStart("jdbcUrl",2)
	 	<div class="layui-btn" onclick="testContention()">测试数据库链接</div> 
	 #@colEnd()
</div>
<div class="layui-row layui-col-space1 task-row">
	#set(req=true,labelWidth=115)
	 #@colStart("标题",12)
	<input type="text" class="layui-input"  name="dataSource.title" value="#(dataSource.title??)" lay-verType='tips'lay-verify="required" maxlength="100"/>
	 #@colEnd() 
</div>

	#@submitButton()

#define js()
<script type="text/javascript">
	var jdbcUrl={
			'mysql':'jdbc:mysql://localhost/database?characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true',
			'oracle':'jdbc:oracle:thin:@127.0.0.1:1521:orcl',
			'ssql':'jdbc:sqlserver://127.0.0.1:1433;DatabaseName=database',
			'psql':'jdbc:postgresql://localhost:5432/database'
		};
	
	 layui.form.on('select(dbTypeFilter)', function(data){
		var dbType=data.value;
		$('#jdbcUrl').val(jdbcUrl[dbType]);
	 });
	 
	function testContention(){
		var user=$('#user').val();
		var password=$("#password").val();
		var jdbcUrl=$("#jdbcUrl").val();
		var dbType=$('dbType').val();
		if(user==''||password==''||jdbcUrl==''){
			layer.msg("必填参数不能为空");
			return;
		}
		var url="#(path)/portal/core/dataSource/debug";
		$.post(url,{'user':user,'password':password,'jdbcUrl':jdbcUrl},function(ret){
			if(ret.state=='ok')
				success(ret.msg);
			else 
				warn(ret.msg)
		});
	}
</script>
#end